package com.zhuss.common;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.zhuss.enums.*;
import org.apache.commons.lang3.StringUtils;

import com.zhuss.bean.unit.linesite.BoardBean;
import com.zhuss.util.DateUtil;
import com.zhuss.util.JsonUtil;
import com.zhuss.util.NoUtil;

public interface BaseVo {

	default String dateStrOnlyMinute(Long date) {
		return DateUtil.toDateTimeStrOnlyMinute(date);
	}

	default String subNo(String no) {
		return NoUtil.simpleNo(no);
	}

	default String resourceTypeName(Integer type) {
		return EnumUtil.containsKey(ResourceType.class, type);
	}

	default String systemName(Integer system) {
		return EnumUtil.containsKey(SystemEnum.class, system);
	}

	default String systemNameCH(Integer system) {
		return EnumUtil.containsKey(SystemCHEnum.class, system);
	}

	default String requestMethodName(Integer requestMethod) {
		return EnumUtil.containsKey(RequestMethod.class, requestMethod);
	}

	default String isName(Integer is) {
		return EnumUtil.containsKey(IsEnum.class, is);
	}

	default String startStopStatusName(Integer status) {
		return EnumUtil.containsKey(StartStopEnum.class, status);
	}

	default String roleTypeName(Integer type) {
		return EnumUtil.containsKey(RoleType.class, type);
	}

	default String companyTypeName(Integer companyType) {
		return EnumUtil.containsKey(CompanyType.class, companyType);
	}

	default String productTypeName(Integer productType) {
		return EnumUtil.containsKey(ProductType.class, productType);
	}

	default String statusNameProduct(Integer status) {
		return EnumUtil.containsKey(UpperDownEnum.class, status);
	}

	default String topicLevelName(Integer level) {
		return EnumUtil.containsKey(TopicLevel.class, level);
	}

	default String priceName(Long price) {
		return new BigDecimal(price).divide(new BigDecimal(100l)) + "";
	}

	default String dateTimeSecondName(Date date) {
		String dateStr = "";
		if (date != null) {
			dateStr = DateUtil.toDateTimeSecondStr(date);
		}
		return dateStr;
	}

	default String dateTimeName(Date date) {
		String dateStr = "";
		if (date != null) {
			dateStr = DateUtil.toDateTimeStr(date);
		}
		return dateStr;
	}

	default String thirdDeptType(Integer type) {
		return EnumUtil.containsKey(公司类型.class, type);
	}

	default String rideTypeName(Integer type) {
		return EnumUtil.containsKey(RideType.class, type);
	}

	default String rideTypeNameSplit(String type) {
	    if (StringUtils.isNotBlank(type)) {
            List<String> asList = new ArrayList<>();
            Stream.of(type.split(",")).forEach(e ->
                    asList.add(rideTypeName(Integer.valueOf(e)))
            );
            String collect = asList.stream().collect(Collectors.joining(","));
            return collect;
        }
	    return "";

	}

	default String holidyTypeName(Integer type) {
		return EnumUtil.containsKey(HolidayType.class, type);
	}

	default String lineTypeName(Integer type) {
		return EnumUtil.containsKey(车辆类型.class, type);
	}

	default List<BoardBean> jsonToList(String board) {

		return JsonUtil.fromJsonList(board, BoardBean.class);

	}
    default String takeTypeName(Integer type) {
        return EnumUtil.containsKey(TakeType.class, type);
    }

    default String sexTypeName(Integer type) {
		return EnumUtil.containsKey(Sex.class, type);
	}

	default String siteType(Integer type) {
		return EnumUtil.containsKey(SiteType.class, type);
	}

	default String operationStatusName(Integer type) {
		return EnumUtil.containsKey(OperationStatus.class, type);
	}

	default String travelPurposeName(Integer type) {
		return EnumUtil.containsKey(TravelPurpose.class, type);
	}

	default String strategyTypeName(Integer type) {
		return EnumUtil.containsKey(StrategyType.class, type);
	}

	default String orderStatusName(Integer status) {
		return EnumUtil.containsKey(订单状态显示.class, status);
	}

	default String canSellName(Integer type) {
		return EnumUtil.containsKey(CanSellType.class, type);
	}

	default String intentionTypeName(Integer type) {
		return EnumUtil.containsKey(IntentionType.class, type);
	}

	default String signStatus(Integer type) {
		return EnumUtil.containsKey(SignStatus.class, type);
	}

	default String noticeTypeName(Integer type) {
		return EnumUtil.containsKey(NoticeType.class, type);
	}
}
